package tec.stan.ling.core;

import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

import tec.stan.ling.core.service.ServiceManager;

/**
 * The activator class controls the plug-in life cycle
 */
public class CorePlugin extends AbstractUIPlugin {

	// The logger
	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger
			.getLogger(CorePlugin.class);

	// The plug-in ID
	public static final String PLUGIN_ID = "tec.stan.ling.core";

	// The shared instance
	private static CorePlugin plugin;

	private ServiceManager manager;

	/**
	 * The constructor
	 */
	public CorePlugin() {
		manager = new ServiceManager();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
	 * )
	 */
	public void start(BundleContext context) throws Exception {
		log.info("CorePlugin start");
		super.start(context);
		plugin = this;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
	 * )
	 */
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
		log.info("CorePlugin end");
	}

	public void load() {
		log.info("core load start");
		manager.load();
		log.info("core load end");
	}

	/**
	 * Returns the shared instance
	 * 
	 * @return the shared instance
	 */
	public static CorePlugin getDefault() {
		return plugin;
	}

	public ServiceManager getServiceManager() {
		return manager;
	}
}
